package com.moshme.web.controller.project;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.moshme.common.core.controller.BaseController;
import com.moshme.common.core.domain.AjaxResult;
import com.moshme.project.domain.dto.StageSurvey;
import com.moshme.project.service.StageSurveyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Kieyfr
 * @version 1.0
 * @description 勘察阶段接口
 * @date 2023/8/29 10:21
 */
@RestController
@RequestMapping("/survey")
public class StageSurveyController extends BaseController {

    @Autowired
    private StageSurveyService stageSurveyService;

    /**
     * 获取勘察阶段
     * */
    @GetMapping({"/{projectId}"})
    @ApiOperation(value = "获取勘察阶段")
    public AjaxResult get(@PathVariable Long projectId) {
        StageSurvey stageSurvey = stageSurveyService.get(projectId);
        if (stageSurvey != null){
            return success(stageSurvey);
        }
        return error("查询失败");
    }

    /**
     * 修改勘察阶段
     */
    @PutMapping
    @ApiOperation(value = "修改勘察阶段")
    public AjaxResult update(@RequestBody StageSurvey stageSurvey) {
        if (stageSurveyService.update(stageSurvey)){
            return success("修改成功");
        }
        return error("修改失败");
    }

}
